package com.youxin.busfoundation.bean.login;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.youxin.busfoundation.enums.EnterpriseIdentifyStatus;
import com.youxin.busfoundation.enums.EnterpriseManagerType;
import com.youxin.busfoundation.enums.EnterprisePassStatus;
import com.youxin.cpcenter.model.TbEntMemberInfo;
import com.youxin.foundation.utils.JsonUtils;
import com.youxin.foundation.utils.StringUtils;

/**
 * 用户信息保存在Redis缓存中
 * 
 * @author yingde.cao
 * @date 2017年12月8日
 * @version 1.0
 */
public class UserInfo {
	/**
	 * 用户主键id
	 */
	private long id;
	/**
	 * 用户uid
	 */
	private String uid;

	/**
	 * 公司邮箱,真实姓名
	 */
	private String email, realname;
	private String phone;
	private String username;
	private String position;
	private TbEntMemberInfo identify;
	
	
	private String token;

	public TbEntMemberInfo getIdentify() {
		return identify;
	}	
	
	public String getPosition() {
		return position;
	}



	public void setPosition(String position) {
		this.position = position;
	}



	/**
	 * 
	 * @description 当前认证企业标识
	 * @return
	 */
	@JsonIgnore
	public long getEntIdentifyId() {
		return identify != null ? identify.getEntIdentifyId().longValue() : 0;
	}
	
	/**
	 * 会员关联企业配置表主键
	 * @description 
	 * @return long
	 */
	@JsonIgnore
	public long getEntMemberId()
	{
		return identify != null ? identify.getId().longValue() : 0;
	}
		
	@JsonIgnore
	public String getCompanyUid()
	{
		return identify != null ? identify.getCompanyUid() : "";
	}
	
	@JsonIgnore
	public String getCompanyName()
	{
		return identify != null ? identify.getCompanyName() : "";
	}

	public void setIdentify(TbEntMemberInfo identify) {
		this.identify = identify;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getRealname() {
		return realname;
	}

	public void setRealname(String realname) {
		this.realname = realname;
	}

	public String getUid() {
		return uid;
	}

	public void setUid(String uid) {
		this.uid = uid;
	}

	/**
	 * 
	 * @description 是否企业认证成员
	 * @return 是的
	 */
	public boolean isMemberIdentity() {
		return identify != null;
	}

	public boolean isMemberIdentityAndPassed() {
		if (isMemberIdentity()) {
			return EnterprisePassStatus.Pass.getValue()==identify.getEnterprisePass().shortValue();
		}
		return false;
	}

	public boolean isAdmin() {
		if (isMemberIdentity()) {			
			return EnterpriseManagerType.Admin.getValue()==identify.getEnterpriseManager().shortValue();
		}
		return false;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return StringUtils.isNullSetEmpty(JsonUtils.objectToFasterxmlJsonString(this));
	}
}
